package com.xcenter.cabinet;

import java.io.File;

import javax.annotation.PostConstruct;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

@Component
@ConfigurationProperties(prefix = "cabinet")
public class CabinetInit {
	
	private static final Logger logger = LoggerFactory.getLogger(CabinetInit.class);
	
	@PostConstruct
	public void init() {
		logger.info("初始化文件柜...");
		File file = new File(root);
		if(file.exists()) {
			logger.info("文件柜已存在");
		} else {
			file.mkdirs();
			logger.info("文件柜已创建，位置：{}", root);
		}
	}

	private String root;
	
	public String getRoot() {
		return root;
	}

	public void setRoot(String root) {
		this.root = root;
	}

}
